<%@ page contentType="text/html; charset=UTF-8" import="java.util.*,com.pub.database.*,com.pub.tools.PublicFunction"%>
<!-- 以下為DataView 共用設定 -->
<jsp:useBean id="DataViewForm" scope="request" class="com.pub.database.DataViewForm"/>
<jsp:setProperty name="DataViewForm" property="submitMethod" value="POST"/>
<jsp:setProperty name="DataViewForm" property="pageRowCount" value="0"/>
<jsp:setProperty name="DataViewForm" property="nowPageNum"/>
<jsp:setProperty name="DataViewForm" property="dataViewAction"/>
<jsp:setProperty name="DataViewForm" property="filterCol"/>
<jsp:setProperty name="DataViewForm" property="filterValue"/>
<jsp:setProperty name="DataViewForm" property="dvOrderByFields"/>
<jsp:setProperty name="DataViewForm" property="dvOrderBySeq"/>
<!-- DataView 設定結束 -->
<%
	ArrayList<ArrayList<Object>> arylstJST = null;
    if(request.getParameter("flownum")==null || request.getParameter("flownum").trim().equals("")){return;}

    String lstrDBAlias=request.getParameter("DB_ALIAS".toLowerCase());
    String lstrDBDebug=request.getParameter("DEBUG".toLowerCase());
    String lstrSrcCharset=request.getParameter("SOURCE_CHARSET".toLowerCase());
    String lstrTgrCharset=request.getParameter("TARGET_CHARSET".toLowerCase());
    String lstrDataViewHtml=null;

    QueryBean qb=new QueryBean(lstrDBAlias,(new Boolean(lstrDBDebug)).booleanValue(), lstrSrcCharset,lstrTgrCharset);

    try{
      if(qb.readSingleValueData("select nvl(count(flow_num),'0') from wkf_jst_eng where flow_num='" + request.getParameter("flownum") + "'").equals("0")){
        out.println("<script type='text/javascript' language='javascript1.2'>alert('查無流程資料!!!');window.close();</script>");
        return;
      }
    }
    catch(Exception e){
      try{qb.close();qb=null;}catch(Exception se){System.out.println("can't close querybean connection in wkf_urge.jsp==>" + se.toString());}
      System.out.println("/PUBPAGE/wkf_urge.jsp exception==>" + e.toString());
      return;
    }

    try{
      arylstJST=qb.querySQL("select flow_desc from floweng_setup where flow_code='" + request.getParameter("flownum").substring(0,3) + "' and flow_no=(select flow_no from wkf_jst_eng where flow_num='" + request.getParameter("flownum") + "' and seqno=(select max(seqno) from wkf_jst_eng where flow_num='" + request.getParameter("flownum") + "'))");
    }
    catch(Exception e){
      try{qb.close();qb=null;}catch(Exception se){System.out.println("can't close querybean connection in wkf_urge.jsp==>" + se.toString());}
      System.out.println("get flowdesc exception in /PUBPAGE/wkf_urge.jsp==>" + e.toString());
      return;
    }

    try{
      StringBuffer stbSQL=new StringBuffer();
      StringBuffer stbPageActionURI=new StringBuffer("wkf_urge.jsp");

      DataViewForm.setFieldsList("wkf_pre_jst.seqno,wkf_pre_jst.flow_no || ' ' || floweng_setup.flow_desc,wkf_jst_eng.jst_flag,wkf_pre_jst.pre_send || ' ' || (select employee_name_c from pnl_employee where wkf_pre_jst.pre_send=employee_no(+)),wkf_jst_eng.s_empno || ' ' || (select employee_name_c from pnl_employee where wkf_jst_eng.s_empno=employee_no(+)),wkf_jst_eng.r_empno || ' ' || decode(nvl(age_empno,''),'',(select employee_name_c from pnl_employee where wkf_jst_eng.r_empno=employee_no(+)),(select employee_name_c from pnl_employee where wkf_jst_eng.r_empno=employee_no(+))||'<br><div align=center><font color=red>('||age_empno||')</font></div>'),to_char(wkf_jst_eng.rec_date_time,'yyyy/MM/dd hh24:mi:ss'),to_char(wkf_jst_eng.app_date_time,'yyyy/MM/dd hh24:mi:ss'),wkf_jst_eng.r_empno");
      DataViewForm.setTablesList("wkf_pre_jst , floweng_setup, wkf_jst_eng");
      DataViewForm.setSQLCondition("( wkf_pre_jst.flow_type = floweng_setup.flow_code (+)) and (wkf_pre_jst.flow_no = floweng_setup.flow_no (+)) and ( wkf_pre_jst.pr_nbr = wkf_jst_eng.flow_num (+)) and ( wkf_pre_jst.seqno = wkf_jst_eng.seqno (+)) and ( ( wkf_pre_jst.pr_nbr = '" + request.getParameter("flownum") + "'))");
      DataViewForm.setOrderByFields("wkf_pre_jst.seqno");
      DataViewForm.setOrderBySeq("asc");
      DataViewForm.setGroupBy(null);
      DataViewForm.setHaving(null);

      String strColRelation[][]=new String[9][];

      strColRelation[0]=new String[3];
      strColRelation[1]=new String[5];
      strColRelation[2]=new String[5];
      strColRelation[3]=new String[3];
      strColRelation[4]=new String[3];
      strColRelation[5]=new String[3];
      strColRelation[6]=new String[3];
      strColRelation[7]=new String[3];
      strColRelation[8]=new String[5];

      strColRelation[0][0]="'序號'";
      strColRelation[0][1]="0";
      strColRelation[0][2]="WIDTH='5%'";		//???e??

      strColRelation[1][0]="'流程說明'";
      strColRelation[1][1]="INPUT";
      strColRelation[1][2]="WIDTH='15%'";		//???e??
      strColRelation[1][3] = "<INPUT class='input_noborder' readonly TYPE=\"TEXT\" NAME=\"flow_desc%sn%\" VALUE="; //TYPE SUBMIT
      //VALUE 屬性務必放於最後面
      strColRelation[1][4] = "1"; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住

      strColRelation[2][0]="'簽核否'";
      strColRelation[2][1]="INPUT";
      strColRelation[2][2]="WIDTH='5%'";		//???e??
      strColRelation[2][3] = "<INPUT class='input_noborder' size='6' readonly TYPE=\"TEXT\" NAME=\"jst_flag%sn%\" VALUE="; //TYPE SUBMIT
      //VALUE 屬性務必放於最後面
      strColRelation[2][4] = "2"; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住

      strColRelation[3][0]="'預收人'";
      strColRelation[3][1]="0";
      strColRelation[3][2]="WIDTH='15%'";

      strColRelation[4][0]="'送件人'";
      strColRelation[4][1]="0";
      strColRelation[4][2]="WIDTH='15%' ";

      strColRelation[5][0]="'收件人'";
      strColRelation[5][1]="0";
      strColRelation[5][2]="WIDTH='15%' ";

      strColRelation[6][0]="'收件日期'";
      strColRelation[6][1]="0";
      strColRelation[6][2]="WIDTH='15%'";

      strColRelation[7][0]="'簽核日期'";
      strColRelation[7][1]="0";
      strColRelation[7][2]="WIDTH='15%' ";

      strColRelation[8][0]="HIDDEN";
      strColRelation[8][1]="INPUT";
      strColRelation[8][2]="WIDTH='0%' ";
      strColRelation[8][3] = "<INPUT TYPE=\"hidden\" size='1' NAME=\"r_empno%sn%\" VALUE="; //TYPE SUBMIT
      //VALUE 屬性務必放於最後面
      strColRelation[8][4] = "8"; //VALUE屬性的值(欄位序號)，若為固定值需以單引號括住

      DataViewForm.setColRelation(strColRelation);//將欄位相關設定殖入ActionForm
      DataViewForm.setTableDataTrHtml("id='tr%sn%' name='tr%sn%' onmouseover=\"if(document.all.item('jst_flag%sn%').value!='N'){this.className='td_content_over';}\" onmouseout=\"if(document.all.item('jst_flag%sn%').value!='N'){this.className='td_content';}\"");
      DataViewForm.setPageBtnOnTop(false);         //將button and rows info 秀在頂端
      DataViewForm.setPageBtnOnButtom(false);      //將button and rows info 秀在底端
      DataViewForm.setFilterShow(false);           //是否要秀出過濾選擇欄位
      DataViewForm.setJumpPageShow(false);         //是否要秀出跳頁下拉式選單
      DataViewForm.setRowsInfoShow(false);         //是否要秀出筆數資訊
      DataViewForm.setRowPageShow(false);          //是否要秀出每頁筆數控制欄
      DataViewForm.setExcelShow(false);           //是否要秀出轉Excel button
      DataViewForm.setOrderEnable(false);          //是否要提供排序點選功能
      DataViewForm.setJumpPageButtonShow(false);   //是否要秀出上下頁按鈕
      DataViewForm.setTableHeaderHtml("class='td_head_grid' align='center'");

      //設定上一頁與下一頁按鈕的form action(通常為母頁即本頁)
      DataViewForm.setPageActionURI(stbPageActionURI.toString());

      com.pub.database.DataView DataView = new com.pub.database.DataView(qb);
      lstrDataViewHtml=DataView.getOutputDataView(DataViewForm);
    }
    catch(Exception e){
      System.out.println("/PUBPAGE/wkf_urge.jsp get DataViewHtml Exception==>" + e.toString());
    }
    finally{
      try{qb.close();}catch(Exception se){System.out.println("can't close querybean connection in wkf_urge.jsp==>" + se.toString());}
      qb=null;
    }
%>

<html>
<head>
<title>跟催</title>
<LINK HREF="/PUBPAGE/general/workflow.css" REL="stylesheet" TYPE="text/css">
  <base target='_self'/>
<script language="javascript" type="text/javascript">
  function setDataView(){
    //開窗置中
    window.moveTo((screen.width-document.body.clientWidth)/2-5,(screen.height-document.body.clientHeight)/2-60);
    //設定已簽列的顏色
    document.all.item('tdFlowDesc').innerHTML='<font color="red"><%=((ArrayList<Object>)arylstJST.get(0)).get(0).toString()%></font>';
    for(i=0;i<document.DataViewForm.elements.length;i++){
      if (document.DataViewForm.elements[i].type=='text' && (document.DataViewForm.elements[i].name.substring(0,8)=='jst_flag')){
        if(document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value=='P'){
          document.all.item('tr' + document.DataViewForm.elements[i].name.substring(8)).bgColor='WHITE';
          document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value='已簽';
        }
        else if(document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value=='N'){
          document.all.item('tr' + document.DataViewForm.elements[i].name.substring(8)).bgColor='EAF2FF';
          document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value='待簽';
        }
        else if(document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value=='M'){
          document.all.item('tr' + document.DataViewForm.elements[i].name.substring(8)).bgColor='EAF2FF';
          document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value='Mail';
        }
        else if(document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value=='C'){
          document.all.item('tr' + document.DataViewForm.elements[i].name.substring(8)).bgColor='EAF2FF';
          document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value='當站取消';
        }
        else if(document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value=='Z'){
          document.all.item('tr' + document.DataViewForm.elements[i].name.substring(8)).bgColor='EAF2FF';
          document.all.item('jst_flag' + document.DataViewForm.elements[i].name.substring(8)).value='當站簽結';
        }

      }
    }
  }

</script>
</head>
<body bgcolor="#ffffff" onload="javascript:setDataView();">
  <TABLE HEIGHT="20" BORDER="0" CELLPADDING="0" CELLSPACING="0">
    <TR>
      <TD ><DIV ALIGN="LEFT"><IMG SRC="/PUBPAGE/pub_images/title/title01.gif" WIDTH="18" HEIGHT="24" HSPACE="0" alt=""></DIV></TD>
      <TD ALIGN="LEFT" HEIGHT="20" VALIGN="MIDDLE" BACKGROUND="/PUBPAGE/pub_images/title/title_bg.gif" CLASS="TITLE">
        跟催明細&nbsp;&nbsp;
      </TD>
      <TD ALIGN="LEFT" HEIGHT="20" VALIGN="MIDDLE" BACKGROUND="/PUBPAGE/pub_images/title/title_bg.gif" id="tdFlowDesc">
      </td>
      <TD BACKGROUND="/PUBPAGE/pub_images/title/title_bg.gif"><DIV ALIGN="RIGHT"><IMG SRC="/PUBPAGE/pub_images/title/title02.gif" WIDTH="18" HEIGHT="24" HSPACE="0" alt=""></DIV></TD>
    </TR>
  </TABLE>
<br/><input type="button" class="button b_normal" value="離開" onclick="window.close()"><br>
  跟催單號：<%=request.getParameter("flownum")%><br>
  <%=lstrDataViewHtml==null?"":lstrDataViewHtml%>
</body>
</html>
